<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>扣率设置</title>
    <script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
    <script type="text/javascript" src="__PUBLIC__/js/jquery.SuperSlide.js"></script>
    

        
        <link rel="stylesheet" href="__PUBLIC__css/public.css">
    <style type="text/css" media="screen">
    table {
        text-align: center;
        margin-left: 0px;
    }
    
    body {
        margin-left: 20px;
    }
    
    tr {
        height: 20px;
    }
    
    td {
        width: 20px;
        background-color: #cccccc;
        border: 0px;
    }
    form{
       
        border: 1px;
    }
    
    label {
        color: red;
    }
    </style>
    <script type="text/javascript">
    function setting(servcode) {

        var ret = "";
        
        $("input[name=" + servcode + "]").each(function() {
            if ($(this).attr('checked')) {
                ret += $(this).val();
                ret += ",";
            }
           

        });
        if(ret.length>1){
             ret=ret.substring(0,ret.length-1);
        }
       
        $.ajax({
                cache: true,
                type: "POST",
                url:"{:U('config/syncConfig')}",
                data:{'servcode':servcode,'value':ret},// 你的formid
                async: false,
                error: function(request) {
                    alert("Connection error");
                },
                success: function(data) {
                   var status = data['status'];
                   alert(data['info']);
                  
                }
            });
        return false;
    }


    /**
     * 动态改变百分比
     * @param  {[type]} servcode [description]
     * @return {[type]}          [description]
     */
    function onclock(servcode){
        var count = 0;
       
         $("input[name=" + servcode + "]").each(function() {
            if ($(this).attr('checked')) {
               count+=1;
            }
           

        });
        var percent = count*0.2*10;
        $('#'+servcode).text(parseInt(percent)+"%");
        //alert(percent);
    }
    </script>
</head>

<body>
    <form action="{:U('config/syncConfig')}" method="Post" accept-charset="utf-8" ons>
        <foreach name="data" item="vo">
            {$vo['key']}扣率:
            <br>
            <foreach name="vo['select']" item="ve">
                {$ve['index']}<input name="{$vo['key']}" type="checkbox" onclick="onclock('{$vo['key']}')"  id="aa" value="{$ve['index']}" {$ve[ 'selected']? "checked=''": ""}/>
                &nbsp;
            </foreach>
            <!-- <input type="text" value="{$vo['value']}" name="{$vo['key']}" style="width: 300px"> -->
            <label id="{$vo['key']}">{$vo['percent']}%</label>
            <input type="submit" class="UIbutton" value="设置" onclick="return setting('{$vo['key']}')">
            <br>
            <br>
            <hr/>
        </foreach>
        <br>
        <br>
      
        <label style="color: red">注:一个数字代表百分之二的比率 1-50内</label>
    </form>
</body>

</html>
